package com.tx.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.tx.admin.controller.po.PagePo;
import com.tx.admin.controller.vo.EntityVo;
import com.tx.admin.controller.vo.PageVo;
import com.tx.admin.entity.TreeEntity;
import com.tx.admin.service.TreeService;

import io.swagger.annotations.ApiOperation;

public abstract class TreeController<E extends TreeEntity<E>> extends SuperController<E> {

	@Autowired
	private TreeService<E> treeService;
	
	  @ApiOperation("查询并构造chldren属性")
	@PostMapping("/findAllBuildChildren")
	public PageVo<E> findAllBuildChildren(@RequestBody PagePo<E> params){
		Page<E> page = treeService.findAllBuildChildren(params);
		PageVo<E> vo = new PageVo<>();
		vo.setPage(page);
		vo.setMsg("查询成功");
		return vo;
	}
	  
	  @ApiOperation("查询并构造parent属性")
	@PostMapping("/findByIdBuildParent")
	public EntityVo<E> findByIdBuildParent(@RequestBody String id) {
		E entity = this.treeService.findByIdBuildParent(id);
		EntityVo<E> vo =  new EntityVo<>();
		vo.setEntity(entity);
		vo.setMsg("查询成功");
		return vo;
	}
}
